It is actually "Oh, my God!", and contains two exclamations: one would be oh, and the other is formed by me ("possessive adjective") and God ("name of the Judeo-Christian divinity").
Oh, my God. Adaptation or Spanishization of the English expression Oh, my god. In Spanish we already have the expression ¡Dios mío! , denoting the same meaning .
OH, MY GOD! Interjection of surprise, which can express as much sorrow or sorrow as joy